﻿using System;
using System.Data;
using System.Configuration;

using System.Web;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Web.UI;
using System.ComponentModel;

using System.Drawing.Design;
using TA.Turbo.Design;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Container control for scenarios, global control references, control reference groups and includes.
	/// </summary>
	[PersistChildren(false)]
	[ParseChildren(true)]
	public class Manager : BaseSpecialControlNoId
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		public Manager()
		{
			//
			// TODO: Add constructor logic here
			//
			this._scenarios = new ScenarioCollection(this);
			this._pageEvents = new PageEventCollection(this);
			this._globalControls = new ControlCollection<GlobalControlReference>(this);
			this._controlReferenceGroups = new ControlCollection<ControlReferenceGroup>(this);
			this._clientIds = new ClientIdCollection(this);
			this.ClientScriptVariablePrefix = "";
		}
		#endregion
		#region PROPS
		[DefaultValue("")]
		public string ClientScriptVariablePrefix { get; set; }
		/// <summary>
		/// List of scenarios which will be added to the global scenario list. Any controls added at this level will be resolved in this manager's naming container first.
		/// </summary>
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public ScenarioCollection Scenarios { get { return _scenarios; } }
		/// <summary>
		/// List of scenarios which will be added to the global scenario list. Any controls added at this level will be resolved in this manager's naming container first.
		/// </summary>
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public PageEventCollection PageEvents { get { return this._pageEvents; } }
		/// <summary>
		/// List of script and style includes. These will be optimized and combined in release mode.
		/// </summary>
		[PersistenceMode(PersistenceMode.InnerProperty)]
		[Editor(typeof(IncludeCollectionEditor), typeof(UITypeEditor))]
		public List<BaseInclude> Includes { get { return this._includes; } }
		/// <summary>
		/// List of controls whose transfer options are set globally.
		/// </summary>
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public ControlCollection<GlobalControlReference> GlobalControls
		{
			get
			{
				return _globalControls;
			}
		}

		/// <summary>
		/// List of control groups which can be added to one or more scenarios.
		/// </summary>
		[PersistenceMode(PersistenceMode.InnerProperty)]
		public ControlCollection<ControlReferenceGroup> Groups
		{
			get
			{
				return _controlReferenceGroups;
			}
		}
		/// <summary>
		/// List of client ID control references.
		/// </summary>
		[PersistenceMode(PersistenceMode.InnerProperty)]
		[Editor(typeof(ClientIdCollectionEditor), typeof(UITypeEditor))]
		public ClientIdCollection ClientIds { get { return this._clientIds; } }
		#endregion
		#endregion
		#region INTERNAL
		#region VARS
		ScenarioCollection _scenarios;
		List<BaseInclude> _includes = new List<BaseInclude>();
		ControlCollection<GlobalControlReference> _globalControls;
		ControlCollection<ControlReferenceGroup> _controlReferenceGroups;
		ClientIdCollection _clientIds;
		PageEventCollection _pageEvents;
		#endregion
		#region INIT
		/// <summary>
		/// INIT
		/// </summary>
		/// <param name="e"></param>
		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			if (!this.get_IsDesignMode())
			{
				TPage.Current.Managers.Add(this);
			}
		}
		#endregion
		#region RENDER
		#endregion
		#endregion
	}
}